<?php

namespace App\Model;

use Util\Common;

/**
 * 订单分类
 */
class OrderType extends Model
{
    const NORMAL_TYPE = 1;//套餐类型;
    const ONE_TYPE = 4;//单篇类型
    const SPECIAL = 5;//专题类型
    const RECEIVING = 2;//定制合同
    const UP_VIP = 3;//升级会员订单
    public bool $timestamps = true;

    protected ?string $table = 'order_type';

    protected array $fillable = [
        'id', 'type', 'price', 'original_price', 'tag', 'describe', 'subtitle', 'order',
        'label', 'discount', 'is_del', 'days', 'count', 'show_price'
    ];
    protected array $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];

    /**获取套餐类型列表
     * @param int $type
     * @return array
     */
    public function getType(int $type):array{
        return self::where('type', $type)
            ->where('is_del', Common::DEL_SHOW)
            ->orderBy('order', 'desc')
            ->get(['id', 'type', 'price', 'original_price', 'tag', 'describe', 'subtitle', 'order', 'label', 'discount', 'days', 'count', 'show_price'])
            ->toArray();
    }
}

